<%@ page language="java" import="java.util.*,service.*,model.*,tools.*" pageEncoding="UTF-8"%>
<%

	String viewerid = (String)request.getAttribute("viewerid");
	String ownerid = (String)request.getAttribute("ownerid");
	String domain = (String)request.getAttribute("domain");
	
	String friendids = request.getParameter("friends");

	String[] friends = friendids.split(",");
	boolean self = viewerid.equals(ownerid);
	SaleData odata = FriendSale.getDataObj(ownerid);
	List<String> slaves = odata.getSlaves();
	int count=0;
%>
	您有现金¥<%=odata.getCash()%>:
<ul>

<%	
	//List<String> cantbuy = new ArrayList<String>();
	//List<SaleData> canbuy = new ArrayList<SaleData>();
	
	for(String friendid:friends){
		friendid = Util.convertToGlobal(domain,friendid);
		if(odata.getMaster()!=null){
		System.out.println("friendid:"+ friendid + " masterid="+odata.getMaster().getId());
		if(friendid.equals(odata.getMaster().getId()))continue;
		}
		if(friendid.equals(ownerid))continue;
		if(slaves.contains(friendid))continue;
		
		SaleData sdata = FriendSale.getDataObj(friendid);
		if(sdata == null)continue;
		if(sdata.getPrice() > odata.getCash())continue;
		Date now = new Date();
		if(now.before(sdata.getBuyUntil()))continue;
		
		Person f = sdata.getPerson();
		
%>
	<li class="choice1"><input type="radio" name="sel" id="sel" value="<%=sdata.getId() %>"    <%=(count==0?"checked":"")%>/>&nbsp;<strong class="f14 dblue"><%=f==null? sdata.getId():f.getName() %></strong>&nbsp;价格:¥<strong class="dgreen"><%=sdata.getPrice() %></strong></li>
			 
<%
	count++;
}

	if(count == 0){
%>
	<li class="choice1">你没有朋友可以买,快去邀请你的朋友加入游戏吧.<li>
<%
	}
%>

</ul>
<div>
<p><input type="button" id="exitbutton" value="&nbsp;&nbsp;确定&nbsp;&nbsp;"/></p>
</div>
<script>
	function check(){
		var v = document.getElementById("sel");
		alert(v.value);
		//fs.buy(v.value);
		
		tb_remove();
		
		//fs.showDialog({title:"some",message:"heyhey"},null);
		
	}
</script>
